package com.costeaalex.blueserver.server;

public class ThreadControlDummyThread extends Thread implements BlueServerSenderThread
	{

	private ThreadManager tML;
	private ThreadControl tC;
	private boolean isAlive;
	private boolean isActive;
	private int id=6;
		
	public ThreadControlDummyThread(ThreadManager tM)
		{
		tML=tM;
		tC=new ThreadControl();
		isAlive=true;
		isActive=true;
		}
	
	@Override
	public void run()
		{
		super.run();
		tML.push(this, tC);
		
		while(isAlive)
			{
			if(isActive)
				{
				block();
				tML.rotate(this);
				}
			}
		}

	public void activate()
		{
		isActive=true;		
		}

	public void block()
		{
		tC.blockThread();
		}

	public void deActivate()
		{
		isActive=false;
		}

	public boolean isActive()
		{
		return isActive;
		}

	public boolean unblockEligible()
		{
		return true;
		}
	
	public int getServiceId()
		{
		return id;
		}
	
	public void destroy()
		{
		isAlive=false;
		}

	public boolean threadIsAlive()
		{
		return isAlive;
		}
	}
